package com.obtk.service.impl;

import com.obtk.mapper.CstOrderMapper;
import com.obtk.mapper.CstServiceMapper;
import com.obtk.model.CstService;
import com.obtk.service.CstServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 功能说明
 *
 * @author Mr.Sun
 * @date 2023-04-04 10:22:39
 */
@Service
public class CstServiceServiceImpl implements CstServiceService {
    @Autowired
    private CstServiceMapper cstServiceMapper;


    @Override
    public List<CstService> selectCstService(CstService cstService) {
        return cstServiceMapper.selectCstService(cstService);
    }

    @Override
    public CstService selectByPlaChCid(Integer plaChcId) {
        return cstServiceMapper.selectByPlaChCid(plaChcId);
    }

    @Override
    public int register(CstService cstService) {
        cstService.setPlaStatus(1);
        cstService.setPlaResult(1);
//        cstService.setPlaDate(new java.sql.Date());
        cstService.setPlaDate(new Date()); // Timestamp 获取当前时间 new Timestamp(System.currentTimeMillis())
        int insert = cstServiceMapper.insert(cstService);
        return insert;
    }

    @Override
    public CstService selectByCstServiceId(Integer plaId) {
        return cstServiceMapper.selectByCstServiceId(plaId);
    }

    @Override
    public int updateByCstServiceId(CstService cstService) {
        cstService.setPlaDate(new Date());
        return cstServiceMapper.updateByCstServiceId(cstService);
    }

    @Override
    public int updateStatusBatch(List<String> plaIds, Integer plaStatus) {
        Map<String,Object> params = new HashMap<String,Object>(2);
        params.put("plaIds",plaIds);
        params.put("plaStatus",plaStatus);
        return cstServiceMapper.updateStatusBatch(params);
    }
}
